//
//  InChargeAlertView.m
//  小小医
//
//  Created by apple on 16/8/15.
//  Copyright © 2016年 ym. All rights reserved.
//

#import "InChargeAlertView.h"
#define LIGHTGREEN [UIColor colorWithRed:108/255.0 green:219/255.0 blue:213/255.0 alpha:1]
#define GRAYTEXT [UIColor colorWithRed:163/255.0 green:163/255.0 blue:153/255.0 alpha:1]
@implementation InChargeAlertView
{
    UIView  *AlertView;
    UITextField *inChargeTF;
    UIImageView *choseAplyImage;
    UIImageView *choseWechatImage;
    NSString *temp;
}
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        temp = @"大图";
        [self createUI];
    }
    return self;
}

- (void)createUI {

    self.backgroundColor = [UIColor colorWithRed:0/255.0 green:0/255.0 blue:0/255.0 alpha:0.3];
    self.frame = CGRectMake(0, 0, Screen_Width, Screen_Height);
    
    AlertView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width - 40, 300 - 60)];
    AlertView.center = self.center;
    AlertView.backgroundColor = [UIColor whiteColor];
    AlertView.layer.masksToBounds = YES;
    AlertView.layer.cornerRadius = 10;
    [self addSubview:AlertView];
    
    UILabel *mMoney = [[UILabel alloc]initWithFrame:CGRectMake(25, 0, 80, 60)];
    mMoney.text = @"筛选形式";
    mMoney.font = [UIFont systemFontOfSize:18];
    [AlertView addSubview:mMoney];
    
    inChargeTF = [[UITextField alloc]initWithFrame:CGRectMake(105, 0, Screen_Width - 40 -105, 60)];
    inChargeTF.font = [UIFont systemFontOfSize:20];
    [AlertView addSubview:inChargeTF];
    [self inPutLine:1];
    
    UILabel *PayWay = [[UILabel alloc]initWithFrame:CGRectMake(25, 60, AlertView.frame.size.width, 60)];
    PayWay.text = @"支付方式";
    PayWay.font = [UIFont systemFontOfSize:18];
//    [AlertView addSubview:PayWay];
    
    [self inPutLine:2];
    
    [self inputAply];
    [self inPutLine:3];
    
    [self inputWeChat];
    
    UIButton *makeSureBut = [UIButton buttonWithType:UIButtonTypeCustom];
    [makeSureBut setBackgroundColor:LIGHTGREEN];
    makeSureBut.frame = CGRectMake(0, 240 - 60, AlertView.frame.size.width, 60);
    [makeSureBut setTitle:@"确定" forState:UIControlStateNormal];
    [makeSureBut setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [makeSureBut addTarget:self action:@selector(MakeSureAction:) forControlEvents:UIControlEventTouchUpInside];
    [AlertView addSubview:makeSureBut];
}

- (void)inPutLine:(NSInteger )index {
    
    UILabel *lineLB = [[UILabel alloc]initWithFrame:CGRectMake(10, 60 *index - 0.5, AlertView.frame.size.width - 20, 0.5)];
    lineLB.backgroundColor = GRAYTEXT;
    [AlertView addSubview:lineLB];
    
}

#pragma mark --- 支付宝
- (void)inputAply {
    UIView * AplyView = [[UIView alloc]initWithFrame:CGRectMake(0, 120 - 60, AlertView.frame.size.width, 60)];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(choseAply)];
    [AplyView addGestureRecognizer:tap];
    
    UIImageView *AplyImge = [[UIImageView alloc]initWithFrame:CGRectMake(25, 15, 30, 30)];
    [AplyImge setImage:[UIImage imageNamed:@"zhifubaoIcon"]];
    
    UILabel *AplyTitle = [[UILabel alloc]initWithFrame:CGRectMake(40, 0, 100, 60)];
    AplyTitle.text = @"大图";
    
    choseAplyImage = [[UIImageView alloc]initWithFrame:CGRectMake(AlertView.frame.size.width - 50, 17.5, 25, 25)];
    choseAplyImage.layer.masksToBounds = YES;
    choseAplyImage.layer.cornerRadius = 25/2;
    [choseAplyImage setImage:[UIImage imageNamed:@"icon_422"]];
    
    [AlertView addSubview:AplyView];
    [AplyView addSubview:AplyTitle];
//    [AplyView addSubview:AplyImge];
    [AplyView addSubview:choseAplyImage];
}

#pragma mark --- 微信
- (void)inputWeChat {
    UIView * AplyView = [[UIView alloc]initWithFrame:CGRectMake(0, 180- 60, AlertView.frame.size.width, 60)];
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(choseWeChat)];
    [AplyView addGestureRecognizer:tap];
    
    UIImageView *AplyImge = [[UIImageView alloc]initWithFrame:CGRectMake(25, 15, 30, 30)];
    [AplyImge setImage:[UIImage imageNamed:@"icon_422"]];
    
    UILabel *AplyTitle = [[UILabel alloc]initWithFrame:CGRectMake(40, 0, 100, 60)];
    AplyTitle.text = @"列表";
    
    choseWechatImage = [[UIImageView alloc]initWithFrame:CGRectMake(AlertView.frame.size.width - 50, 17.5, 25, 25)];
    choseWechatImage.layer.masksToBounds = YES;
    choseWechatImage.layer.cornerRadius = 25/2;
    [choseWechatImage setImage:[UIImage imageNamed:@"icon_422"]];
    
    [AlertView addSubview:AplyView];
    [AplyView addSubview:AplyTitle];
//    [AplyView addSubview:AplyImge];
    [AplyView addSubview:choseWechatImage];
}

- (void)choseAply {
    temp = @"大图";
    [choseAplyImage setImage:[UIImage imageNamed:@"icon_522"]];
    [choseWechatImage setImage:[UIImage imageNamed:@"icon_422"]];
    if (self.ChoseAplyBlock) {
        self.ChoseAplyBlock();
    }
}

- (void)choseWeChat {
    temp = @"列表";
    [choseWechatImage setImage:[UIImage imageNamed:@"icon_522"]];
    [choseAplyImage setImage:[UIImage imageNamed:@"icon_422"]];
    if (self.ChoseWeChatBlock) {
        self.ChoseWeChatBlock();
    }
}

- (void)MakeSureAction:(UIButton *)sender {
    if (self.MakeSureBlock) {
        self.MakeSureBlock(temp);
    }
    [self hidden];
}
- (void)show {
    [[[UIApplication sharedApplication] keyWindow] addSubview:self];
}

- (void)hidden {
    [self removeFromSuperview];
}
@end
